﻿using DBUtility;
using gfLibrary;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IYAKASAPortal.Standard
{
    public partial class CALIB_ZB_DATA_LIST : System.Web.UI.Page
    {

        private string m_lineNum = string.Empty;
        private string m_devCalibName = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                m_lineNum = "1";
                BindDataToRptList();
               // BindDropDownList();
              
            }
           
        }

        public DataTable GetDataTable(string lineNum)
        {
            DbStoredProcedure DBSPHelper = new DbStoredProcedure();

            SqlParameter[] sqlParams = new SqlParameter[]
            {
                new SqlParameter("@lineNum",lineNum)
               
            };

            DataTable dt = new DataTable();
            DBSPHelper.GetProcDataTable(ref dt,"proc_NET_AJ_JK_RESULT_GetZBSJData",sqlParams);
            return dt;

        }

        private void BindDropDownList()
        {
            #region 绑定检测项目
            //string sql = "SELECT  DevCalibName FROM CALIB_DATA GROUP BY  DevCalibName ";
            //DataTable dt = new DataTable();

            //dt.Columns.Add("ID",typeof(int));
 

            //DbHelper.GetTable(sql,ref dt);

            //int i = 0;
            //foreach (DataRow dr in dt.Rows)
            //{
            //    dr["ID"] = i;
            //    i++;
            //}
            //ddlProject.DataSource = dt;
            //ddlProject.DataTextField = "DevCalibName";
            //ddlProject.DataValueField = "ID";
            //ddlProject.DataBind();
           
            
            #endregion
        }

        private void BindDataToRptList()
        {
            try
            {
                DataTable dt = GetDataTable(m_lineNum);
                rptList.DataSource = dt;
                rptList.DataBind();
            }
            catch (Exception ex)
            {

            }
        }

        protected void ddlProject_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void ddlProject_TextChanged(object sender, EventArgs e)
        {
           
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            m_lineNum = ddlLineNum.SelectedItem.Text;
           // m_devCalibName = ddlProject.SelectedItem.Text;
            BindDataToRptList();
        }

        protected void btnBrowse_Click(object sender, EventArgs e)
        {
            //string strUniqueKey = Request.Form["txtUniqueKey"];
            string strJCXH = Request.Form["JCXH"];
            string strDevCalibName = Request.Form["DevCalibName"];
            string strDevName = Request.Form["DevName"];
            if ((strJCXH == null) || (strJCXH.Length == 0) || (strDevCalibName == null) || (strDevCalibName.Length == 0))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择一条记录！");
                return;
            }
            Response.Redirect(string.Format("CALIB_ZB_DATA_LIST_VIEW.aspx?JCXH={0}&DevCalibName={1}&DevName={2}", strJCXH, strDevCalibName,strDevName));
        }

    }
}